<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /**
       * @param {string} s
       * @return {boolean}
       */
      var isPalindrome = function (s) {
        // debugger
        // 整理字符串
        var patt = /[a-z0-9]/gi; // 全局匹配 不区分大小写
        s = s.match(patt);
        if(!s) return true;
        for (var i = 0; i < Math.floor(s.length / 2); i++) {
          if (s[i].toLowerCase() !== s[s.length - 1 - i].toLowerCase()) return false;
        }
        return true;
      };

      var s = "0P";
      console.log(isPalindrome(s));
    </script>
  </body>
</html>
